﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Biz;
using Biz.Check;
using Ext.Net;

namespace Web
{
    public partial class CheckListVIew : PageHelper
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                if (CurrentUser == null)
                    return;
                if (Session["CURRENT_CHECK_LIST"] == null)
                {
                    rType.Value = "非公务人员";
                    return;
                }
                if (Session["CURRENT_CHECK_LIST"] != null)
                {
                    switch (((CheckList)Session["CURRENT_CHECK_LIST"]).PRODUCT_NAME)
                    {
                        case "ChineseCivilServant":
                            ckForChineseCivilServant c = (ckForChineseCivilServant)Session["CURRENT_CHECK_LIST"];
                            rType.Value = "中国公务人员";
                            cCB1.Checked = c.CheckItem01;
                            cCB2.Checked = c.CheckItem02;
                            cCB3.Checked = c.CheckItem03;
                            cCB4.Checked = c.CheckItem04;
                            cCB5.Checked = c.CheckItem05;
                            cCB6.Checked = c.CheckItem06;
                            cCB7.Checked = c.CheckItem07;
                            break;

                        case "JapaneseCivilServant":
                            ckForJapaneseCivilServant j = (ckForJapaneseCivilServant)Session["CURRENT_CHECK_LIST"];
                            rType.Value = "日本公务人员";
                            pCB1.Checked = j.CheckItem01;
                            pCB2.Checked = j.CheckItem02;
                            pCB3.Checked = j.CheckItem03;
                            pCB4.Checked = j.CheckItem04;
                            pCB5.Checked = j.CheckItem05;
                            pCB6.Checked = j.CheckItem06;
                            pCB7.Checked = j.CheckItem07;
                            pCB8.Checked = j.CheckItem08;
                            pCB9.Checked = j.CheckItem09;
                            break;

                        case "OtherCivilServant":
                            ckForOtherCivilServant o = (ckForOtherCivilServant)Session["CURRENT_CHECK_LIST"];
                            rType.Value = "其他公务人员";
                            oCB1.Checked = o.CheckItem01;
                            oCB2.Checked = o.CheckItem02;
                            oCB3.Checked = o.CheckItem03;
                            oCB4.Checked = o.CheckItem04;
                            oCB5.Checked = o.CheckItem05;
                            oCB6.Checked = o.CheckItem06;
                            break;
                    }
                }
            }
        }

        protected void Type_Change(object sender, DirectEventArgs e)
        {
            switch (rType.Value.ToString())
            {
                case "非公务人员":
                    pCServant.Hidden = true;
                    pJServant.Hidden = true;
                    pOServant.Hidden = true;
                    break;

                case "中国公务人员":
                    pCServant.Hidden = false;
                    pJServant.Hidden = true;
                    pOServant.Hidden = true;
                    break;

                case "日本公务人员":
                    pCServant.Hidden = true;
                    pJServant.Hidden = false;
                    pOServant.Hidden = true;
                    break;

                case "其他公务人员":
                    pCServant.Hidden = true;
                    pJServant.Hidden = true;
                    pOServant.Hidden = false;
                    break;
            }
        }

        protected void Save_Click(object sender, DirectEventArgs e)
        {
            switch (rType.Value.ToString())
            {
                case "非公务人员":
                    Session["CURRENT_CHECK_LIST"] = null;
                    break;

                case "中国公务人员":
                    ckForChineseCivilServant c = new ckForChineseCivilServant();
                    c.CheckItem01 = cCB1.Checked;
                    c.CheckItem02 = cCB2.Checked;
                    c.CheckItem03 = cCB3.Checked;
                    c.CheckItem04 = cCB4.Checked;
                    c.CheckItem05 = cCB5.Checked;
                    c.CheckItem06 = cCB6.Checked;
                    c.CheckItem07 = cCB7.Checked;                    
                    Session["CURRENT_CHECK_LIST"] = c;
                    break;

                case "日本公务人员":
                    ckForJapaneseCivilServant j = new ckForJapaneseCivilServant();
                    j.CheckItem01 = pCB1.Checked;
                    j.CheckItem02 = pCB2.Checked;
                    j.CheckItem03 = pCB3.Checked;
                    j.CheckItem04 = pCB4.Checked;
                    j.CheckItem05 = pCB5.Checked;
                    j.CheckItem06 = pCB6.Checked;
                    j.CheckItem07 = pCB7.Checked;
                    j.CheckItem08 = pCB8.Checked;
                    j.CheckItem09 = pCB9.Checked;                 
                    Session["CURRENT_CHECK_LIST"] = j;
                    break;

                case "其他公务人员":
                    ckForOtherCivilServant o = new ckForOtherCivilServant();
                    o.CheckItem01 = oCB1.Checked;
                    o.CheckItem02 = oCB2.Checked;
                    o.CheckItem03 = oCB3.Checked;
                    o.CheckItem04 = oCB4.Checked;
                    o.CheckItem05 = oCB5.Checked;
                    o.CheckItem06 = oCB6.Checked;        
                    Session["CURRENT_CHECK_LIST"] = o;
                    break;
            }

        }
    }
}